/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package foxmob.mlts.viewcontroller.setter;

import foxmob.mlts.controller.setter.OpenTestRecordFormController;
import foxmob.mlts.controller.setter.SetterFormController;
import javax.swing.JList;

/**
 *
 * @author Lunayo
 */
public class OpenTestRecordForm extends javax.swing.JFrame {

    /**
     * Creates new form OpenTestRecordForm
     */
    public OpenTestRecordForm(SetterFormController delegate) {
        initComponents();
        openTestRecordFormController = 
                new OpenTestRecordFormController(delegate, this);
        openTestRecordFormController.loadTestRecord();
    }
    
    public JList getRecordList() {
        return this.recordList;
    }
    
    public OpenTestRecordFormController getOpenTestRecordFormController() {
        return this.openTestRecordFormController;
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        openRecordPanel = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        recordList = new javax.swing.JList();
        okButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        openRecordPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Open Existing Record"));

        recordList.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                recordListMouseEventListener(evt);
            }
        });
        recordList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                listSelectionHandler(evt);
            }
        });
        jScrollPane1.setViewportView(recordList);

        okButton.setText("OK");
        okButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                okButtonActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout openRecordPanelLayout = new org.jdesktop.layout.GroupLayout(openRecordPanel);
        openRecordPanel.setLayout(openRecordPanelLayout);
        openRecordPanelLayout.setHorizontalGroup(
            openRecordPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(openRecordPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(openRecordPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 405, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, openRecordPanelLayout.createSequentialGroup()
                        .add(0, 0, Short.MAX_VALUE)
                        .add(okButton)))
                .addContainerGap())
        );
        openRecordPanelLayout.setVerticalGroup(
            openRecordPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(openRecordPanelLayout.createSequentialGroup()
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(okButton))
        );

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(openRecordPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(0, 0, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(openRecordPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(0, 0, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void listSelectionHandler(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_listSelectionHandler
        // TODO add your handling code here:
        openTestRecordFormController.listSelectionDidSelect();
    }//GEN-LAST:event_listSelectionHandler

    private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
        // TODO add your handling code here:
        openTestRecordFormController.okButtonDidTap();
    }//GEN-LAST:event_okButtonActionPerformed

    private void recordListMouseEventListener(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_recordListMouseEventListener
        // TODO add your handling code here:
        openTestRecordFormController.recordListMouseDidClick(evt);
    }//GEN-LAST:event_recordListMouseEventListener

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(OpenTestRecordForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(OpenTestRecordForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(OpenTestRecordForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(OpenTestRecordForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JButton okButton;
    private javax.swing.JPanel openRecordPanel;
    private javax.swing.JList recordList;
    // End of variables declaration//GEN-END:variables

    private OpenTestRecordFormController openTestRecordFormController;
}
